class OauthClient
  include OauthModule

  attr_accessor :access_token, :token_info

  def initialize(token_resp, token: 'access_token')
    @token_info = Oj.load(token_resp)
    @access_token = @token_info[token]
  end

  def get(url, headers={}, &block)
    headers[:params] = (headers[:params] || {}).merge access_token: access_token
    RestClient::Request.execute(method: :get, url: url, headers: headers, &block)
  end

  def post(url, payload={}, headers={}, &block)
    payload = payload.merge access_token: access_token
    RestClient::Request.execute(method: :post, url: url, payload: payload, headers: headers, &block)
  end
end